import re

# A0 = dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))
# A1 = list(range(0,10,2) )
# A2 = [i for i in A1 if i in A0]  #
# A3 = [A0[s] for s in A0]   #
# A4 = [i for i in A1 if i in A3]  #
# print(A0,A1,A2,A3,A4)

# n = int(input())
# sum = 0
# for i in range(1,n+1,2):
#     s = 1
#     for j in range(1, i + 1):
#         s *= j
#     sum += s
# print("n=" + str(n), end=',')
# print("s=" + str(sum))


# import pymysql
# connect_info={'host':'localhost','port':3306,'user':'root','password':'123456',
#               'database':'school','charset':'utf8'}
# cnn=pymysql.connect(**connect_info)
# cur=cnn.cursor()
# sql='select sno,sname,avg(sc) from student left join score on ' \
#     'student.sno=score.sno group by sno having order by avg(sc) desc'
# cur.execute(sql)
# cur.fetchall()
# cur.close()
# cnn.close()

# def jc(n):
#     if n ==1:
#         return 1
#     else:
#         return n*jc(n-1)
#
# list=[1,3,5,7,9]
# sum=0
# for i in list:
#     sum+=jc(i)
# print(sum)












# 8.请基于requests库对http://192.168.3.13/woniusalse网址模拟GET请求，至少三种不同的写法。(5分)
# import requests
# url = 'http://192.168.3.13/woniusalse'
# r = requests.get(url)
# r = requests.request('get',url)
# r = requests.session().get(url)

# 9.s='e%,b2c1d3a4#5'，分别找出该字符串中的数字和字母，将字母和数字组成键值对放入字典中，结果为{'a':1,'b':2,'c':3,'d':4,'e':5}  【提示 数字 和 字母 都是升序】
# import re
# s='e%,b2c1d3a4#5'
# w = re.findall('[a-z]',s)
# w.sort()
# d = re.findall('\d',s)
# d.sort()
# d = [int(i) for i in d]
# print(dict(zip(w,d)))

# 10.利用Python封装一个函数（post_2_dict()）实现将POST请求正文(key=value,key=value)转换为字典对象，并返回该字典对象。（5分）。
# string='key=value,key=value' 

# string='key=value,key1=value1'
# def post_2_dict(string):
#     d={}
#     s = string.split(',')
#     for i in s:
#         k,v = i.split('=')
#         d[k]=v
#     return d
#
# print(post_2_dict(string))

# 11.根据接口文档，编写接口测试用例（10分），并利用requests库实现接口测试脚本。(10分)
# import requests
# url = 'http://localhost:8080/woniusales/customer/add'
# data1 = {'customername':'feiyang','customerphone':'15756492603','childsex':'男','childdate':'1996-05-24','creditkids':'0','creditcloth':'0'}
# data2 = {'customername':'','customerphone':'15756492604','childsex':'男','childdate':'1996-05-24','creditkids':'0','creditcloth':'0'}
# data3 = {'customername':'feiyang','customerphone':'1575649260','childsex':'男','childdate':'1996-05-24','creditkids':'0','creditcloth':'0'}
# data4 = {'customername':'feiyang11','customerphone':'15756492603','childsex':'男','childdate':'1996-05-24','creditkids':'0','creditcloth':'0'}
# login = {'username':'admin','password':'admin123','verifycode':'0000'}
# r = requests.session()
# r.get('http://localhost:8080/woniusales/user/login',params=login)
#
# r1 = r.post(url,data1)
# print(r1.text)
# assert r1.text == 'add-successful'
#
# r2 = r.post(url,data2)
# print(r2.text)
# assert r2.text == 'add-failed'
#
# r3 = r.post(url,data3)
# print(r3.text)
# assert r3.text == 'add-failed'
#
# r4 = r.post(url,data4)
# print(r4.text)
# assert r4.text == 'already-added'




# 读取excel
from openpyxl import Workbook,load_workbook
from openpyxl.styles import *

filename=r"C:\Users\Administrator\Desktop\接口测试文档.xlsx"
wb = load_workbook(filename)
print(wb)
ws = wb['API_2']
print(ws.title)
for i in ws.values:
    print(i)


# nrows=sheet1.nrows
# list = []
# for r in range(nrows):
#     r_values=sheet1.row_values(r)  # 取行数据，参数0为第一行。
#     if r != 0:
#         a= dict(zip(sheet1.row_values(0),r_values))
#         list.append(a)
# print(list)















